﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using MultiLanguage;
using MultiLanguage.Infrastructure;
namespace UnitTests
{
    [TestClass]
    public class ViewModelTests
    {
        private const string InputTemperature = "InputTemperature";
        [TestMethod, Description("Test graceful behaviour with null arguments")]
        public void InstanceTest()
        {
            var vm = new TemperatureConverterViewModel(null, null);
            Assert.IsTrue(vm !=null);
            Assert.IsTrue(vm.SupportedCultures.Count>0);
            var status = vm[InputTemperature];
            Assert.IsNull(status);
            Assert.IsTrue(vm.OutputTemperature.Length==0);
            Assert.IsTrue(vm.SetCultureCommand.CanExecute(null));
        }
        [TestMethod, Description("Perform some conversions through the View Model")]
        public void BasicFunctionality()
        {
            ITemperatureConverter converter = new TemperatureConverter();
            var vm = new TemperatureConverterViewModel(converter, null) {InputTemperature = "100"};
            var status = vm[InputTemperature];
            Assert.IsNull(status);
            Assert.IsTrue(vm.OutputTemperature.Contains("212"));
            vm.IsDirectionalToggleChecked = true;
            Assert.IsTrue(vm.OutputTemperature.StartsWith("37"));
        }
    }
}
